package cn.edu.sdjzu.demoresttemplate.controller;

import cn.edu.sdjzu.demoresttemplate.bean.ResponseBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    /**
     * 不带参的get请求
     * @return
     */
    @RequestMapping(value = "testGet", method = RequestMethod.GET)
    public ResponseBean testGet(){
        ResponseBean result = new ResponseBean();
        result.setCode("200");
        result.setMsg("请求成功，方法：testGet");
        return result;
    }

    @RequestMapping(value = "testGetByParams", method = RequestMethod.GET)
    public ResponseBean testGetParams(@RequestParam("userName") String userName, @RequestParam("password") String password){
        ResponseBean result = new ResponseBean();
        result.setCode("200");
        result.setMsg("请求成功，方法：testGet,"+"userName:"+userName+","+"password:"+password);
        return result;
    }
}

